ko.extensions.webos.dialogFolder = function()
{
    const nsIFilePicker = Components.interfaces.nsIFilePicker;

    var fp = Components.classes["@mozilla.org/filepicker;1"]
                       .createInstance(nsIFilePicker);
    fp.init(window, "Dialog Title", nsIFilePicker.modeGetFolder);
    fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
    
    var rv = fp.show();
    if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace)
    {
        var file = fp.file;
        var path = fp.file.path;
        alert(path);
        var file = Components.classes["@mozilla.org/file/local;1"].
                              createInstance(Components.interfaces.nsILocalFile);
        file.initWithPath(path);
        alert(file.isDirectory());
        var entries = file.directoryEntries;
        var array = [];
        while(entries.hasMoreElements())
        {
          var entry = entries.getNext();
          entry.QueryInterface(Components.interfaces.nsIFile);
          array.push(entry);
        }
        alert('noerror');
        for(var i in array)
        {
            alert(i + " " + array[i].path);
        }
        return {path:path};
    }
    else
    {
        return {path:""};
    }
}